<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
        }
        
        .bgc {
            background-color: purple;
        }
    </style>
    <script src="../../vue.js"></script>
</head>

<body>
    <div class="box">
        <div :class='{active : isactive , bgc : isbgc}'> 对象形式的样式</div>
        <div :class='[ activeClass , bgcClass]'> 数组形式的样式</div>
        <button @click='handle'>切换</button>
    </div>
    <script>
        let vm = new Vue({
            el: '.box',
            data: {
                isactive: true,
                isbgc: true,
                activeClass: 'active',
                bgcClass: 'bgc',
            },
            methods: {
                handle() {
                    this.isactive = !this.isactive
                    this.isbgc = !this.isbgc
                    this.activeClass = ''
                    this.bgcClass = ''
                }
            }
        })
    </script>
</body>

</html>